clang tidy uses const_cast.
authortsteven4 <tsteven4@gmail.com>
Thu, 28 Jun 2018 14:04:06 +0000 (08:04 -0600)
committertsteven4 <tsteven4@gmail.com>
Thu, 28 Jun 2018 14:04:06 +0000 (08:04 -0600)
This was from the google-readability-casting check,
but only Message: C-style casts are discouraged; use const_cast
were accepted.

25 files changed:
an1sym.h
arcdist.cc
cet.cc
cet_util.cc
compegps.cc
cst.cc
csv_util.cc
discard.cc
garmin_txt.cc
gdb.cc
height.cc
humminbird.cc
lowranceusr4.cc
mmo.cc
osm.cc
position.cc
raymarine.cc
reverse_route.cc
route.cc
stmsdf.cc
swapdata.cc
trackfilter.cc
unicsv.cc
util.cc
vecs.cc

index 2e33d3094c8d34764e7a95f69bdc207efda13f10..ee0e02e4e8e99fe655fbc66a45947e16b15e6a77 100644 (file)
--- a/an1sym.h
+++ b/an1sym.h
@@ -725,7 +725,7 @@ static int FindIconByGuid(GUID* guid, char** name)
   unsigned int i = 0;
   for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
     if (!memcmp(guid, &default_guids[i].guid, sizeof(GUID))) {
-      *name = (char*) default_guids[i].name;
+      *name = const_cast<char*>(default_guids[i].name);
       return 1;
     }
   }
index 1b95c0688a3a176b8027add3098cf3808abee101..679a02b5e22ada1356a960982f9fe213f2c07de2 100644 (file)
@@ -87,14 +87,14 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2)
             ed->prjlongitude = prjlon;
             ed->frac = frac;
             ed->arcpt1 = arcpt1;
-            ed->arcpt2 = (Waypoint*) arcpt2;
+            ed->arcpt2 = const_cast<Waypoint*>(arcpt2);
           }
         }
         waypointp->extra_data = ed;
       }
     }
   }
-  arcpt1 = (Waypoint*) arcpt2;
+  arcpt1 = const_cast<Waypoint*>(arcpt2);
 }
 
 void ArcDistanceFilter::arcdist_arc_disp_hdr_cb(const route_head*)
diff --git a/cet.cc b/cet.cc
index bd14b8fad06e605d6e4cd0a97f4a3ebd32b3bd76..ecb036d1313ebc992742db5349e9b2cf08cebc2e 100644 (file)
--- a/cet.cc
+++ b/cet.cc
@@ -163,7 +163,7 @@ cet_utf8_to_ucs4(const char* str, int* bytes, int* value)
           if ((*cp & 0xc0) != 0x80) {
             break;  /* invalid         */
           } else if (i == 0) {         /* all valid    */
-            char* c = (char*)str;              /* found valid sequence, now storing value */
+            char* c = const_cast<char*>(str);          /* found valid sequence, now storing value */
             int res = *c++ & (mask ^ 0xFF);
             i = len;
             while (i-- > 0) {
@@ -205,7 +205,7 @@ cet_ucs4_to_char(const int value, const cet_cs_vec_t* vec)
 {
   cet_ucs4_link_t* link;
 
-  if ((link = (cet_ucs4_link_t*)vec->ucs4_link)) {
+  if ((link = const_cast<cet_ucs4_link_t*>(vec->ucs4_link))) {
     int i = 0;
     int j = vec->ucs4_links - 1;                       /* validate ucs value against vec */
     while (i <= j) {
@@ -222,7 +222,7 @@ cet_ucs4_to_char(const int value, const cet_cs_vec_t* vec)
     }
   }
 
-  if ((link = (cet_ucs4_link_t*)vec->ucs4_extra)) {    /* can be NULL */
+  if ((link = const_cast<cet_ucs4_link_t*>(vec->ucs4_extra))) {        /* can be NULL */
     int i = 0;
     int j = vec->ucs4_extras - 1;
     while (i <= j) {
@@ -362,7 +362,7 @@ cet_utf8_strndup(const char* str, const int maxlen)
 char*
 cet_str_utf8_to_any(const char* src, const cet_cs_vec_t* vec)
 {
-  char* c = (char*)src;
+  char* c = const_cast<char*>(src);
   int len;
   char* res, *dest, *cend;
 
@@ -400,7 +400,7 @@ cet_str_any_to_utf8(const char* src, const cet_cs_vec_t* vec)
   char* result, *cin, *cout;
   char temp = CET_NOT_CONVERTABLE_DEFAULT;
 
-  cin = (char*)src;
+  cin = const_cast<char*>(src);
   if (cin == nullptr) {
     return nullptr;
   }
@@ -417,7 +417,7 @@ cet_str_any_to_utf8(const char* src, const cet_cs_vec_t* vec)
   }
 
   result = cout = (char*) xmalloc(len + 1);
-  cin = (char*)src;
+  cin = const_cast<char*>(src);
 
   while (*cin != '\0') {
     if (CET_ERROR == cet_char_to_ucs4(*cin++, vec, &value)) {
index 122b3f17cd4f743393f976b38152dc66c6f7b686..e915170f680218f91c99fc6f14e4cec1f31fb8dc 100644 (file)
@@ -155,7 +155,7 @@ cet_register()
     for (p = cet_cs_vec_root; p != nullptr; p = p->next) {
       c++;
       if (p->alias != nullptr) {
-        char** a = (char**)p->alias;
+        char** a = const_cast<char**>(p->alias);
         while ((*a) != nullptr) {
           a++;
           c++;
@@ -168,7 +168,7 @@ cet_register()
     i = 0;
     for (p = cet_cs_vec_root; p != nullptr; p = p->next) {
       if (p->alias != nullptr) {
-        char** a = (char**)p->alias;
+        char** a = const_cast<char**>(p->alias);
 
         list[i].name = xstrdup(p->name);
         list[i].vec = p;
@@ -322,13 +322,13 @@ cet_convert_init(const QString& cs_name, const int force)
 static void
 cet_flag_waypt(const Waypoint* wpt)
 {
-  ((Waypoint*)(wpt))->wpt_flags.cet_converted = 1;
+  (const_cast<Waypoint*>(wpt))->wpt_flags.cet_converted = 1;
 }
 
 static void
 cet_flag_route(const route_head* rte)
 {
-  ((route_head*)(rte))->cet_converted = 1;
+  (const_cast<route_head*>(rte))->cet_converted = 1;
 }
 
 static void
@@ -391,7 +391,7 @@ cet_convert_string(const QString& str)
 static void
 cet_convert_waypt(const Waypoint* wpt)
 {
-  Waypoint* w = (Waypoint*)wpt;
+  Waypoint* w = const_cast<Waypoint*>(wpt);
   format_specific_data* fs;
 
   if ((cet_output == 0) && (w->wpt_flags.cet_converted != 0)) {
@@ -414,7 +414,7 @@ cet_convert_waypt(const Waypoint* wpt)
 static void
 cet_convert_route_hdr(const route_head* route)
 {
-  route_head* rte = (route_head*)route;
+  route_head* rte = const_cast<route_head*>(route);
 
   if ((cet_output == 0) && (rte->cet_converted != 0)) {
     return;
@@ -454,8 +454,8 @@ cet_convert_strings(const cet_cs_vec_t* source, const cet_cs_vec_t* target, cons
     cet_output = 1;
 
     converter = cet_convert_from_utf8;
-    cs_name_from = (char*)cet_cs_vec_utf8.name;
-    cs_name_to = (char*)target->name;
+    cs_name_from = const_cast<char*>(cet_cs_vec_utf8.name);
+    cs_name_to = const_cast<char*>(target->name);
   } else {
     if ((target != nullptr) && (target != &cet_cs_vec_utf8)) {
       fatal(MYNAME ": Internal error!\n");
@@ -464,8 +464,8 @@ cet_convert_strings(const cet_cs_vec_t* source, const cet_cs_vec_t* target, cons
     cet_output = 0;
 
     converter = cet_convert_to_utf8;
-    cs_name_to = (char*)cet_cs_vec_utf8.name;
-    cs_name_from = (char*)source->name;
+    cs_name_to = const_cast<char*>(cet_cs_vec_utf8.name);
+    cs_name_from = const_cast<char*>(source->name);
   }
 
   if (global_opts.debug_level > 0) {
index b9a098016a9065e56203b75e8534967b94162a74..74be6fa81bc5e7c9ba8a1fd3b30b20d7b83ed39e 100644 (file)
@@ -514,7 +514,7 @@ write_waypt_cb(const Waypoint* wpt)
 static void
 write_route_hdr_cb(const route_head* rte)
 {
-  curr_route = (route_head*) rte;
+  curr_route = const_cast<route_head*>(rte);
   curr_index++;
   if (curr_index != target_index) {
     return;
@@ -540,7 +540,7 @@ static void
 write_track_hdr_cb(const route_head* trk)
 {
   track_info_flag = 0;
-  curr_track = (route_head*) trk;
+  curr_track = const_cast<route_head*>(trk);
 
   curr_index++;
   if (curr_index != target_index) {
diff --git a/cst.cc b/cst.cc
index 8a55f9f17e0039b5ce1073ec1da5c3e0ac2a38c4..27f1fb7357a581b61ad74274ac6f053ffee154a7 100644 (file)
--- a/cst.cc
+++ b/cst.cc
@@ -69,7 +69,7 @@ cst_add_wpt(const route_head* track, Waypoint* wpt)
     }
     route_add_wpt(temp_route, new Waypoint(*wpt));
   }
-  track_add_wpt((route_head*)track, wpt);
+  track_add_wpt(const_cast<route_head*>(track), wpt);
 }
 
 static char*
index 36972bf7c34d3f827e517cbad7293272c53f3048..439f6f191c18d25fdec7a1eb606747b200e645dd 100644 (file)
@@ -489,7 +489,7 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which)
       *c = '.';
     }
   } else {
-    buff = (char*)instr;
+    buff = const_cast<char*>(instr);
   }
 
   cur = buff;
@@ -1566,10 +1566,10 @@ xcsv_resetpathlen(const route_head* head)
   csv_route = csv_track = nullptr;
   switch (xcsv_file.datatype) {
   case trkdata:
-    csv_track = (route_head*) head;
+    csv_track = const_cast<route_head*>(head);
     break;
   case rtedata:
-    csv_route = (route_head*) head;
+    csv_route = const_cast<route_head*>(head);
     break;
   default:
     break;
index e5b5de10a32f979414e07da5369e825b0f099a8a..18fa362144f97f4a1ea6fbf68eb13d8d788814ac 100644 (file)
@@ -39,7 +39,7 @@ void DiscardFilter::fix_process_wpt(const Waypoint* wpt)
   int delh = 0;
   int delv = 0;
 
-  Waypoint* waypointp = (Waypoint*) wpt;
+  Waypoint* waypointp = const_cast<Waypoint*>(wpt);
 
   if ((hdopf >= 0.0) && (waypointp->hdop > hdopf)) {
     delh = 1;
@@ -107,7 +107,7 @@ void DiscardFilter::fix_process_wpt(const Waypoint* wpt)
 
 void DiscardFilter::fix_process_head(const route_head* trk)
 {
-  head = (route_head*)trk;
+  head = const_cast<route_head*>(trk);
 }
 
 void DiscardFilter::process()
index 1f0b7805a2db43975270f1260393a2b1feb294ab..fcb6cda8e50c22403b7bb7eb4afa1e3cacf4e670 100644 (file)
@@ -212,13 +212,13 @@ enum_waypt_cb(const Waypoint* wpt)
     for (i = 0; i < wpt_a_ct; i++) {           /* check for duplicates */
       Waypoint* tmp = wpt_a[i];
       if (case_ignore_strcmp(tmp->shortname, wpt->shortname) == 0) {
-        wpt_a[i] = (Waypoint*)wpt;
+        wpt_a[i] = const_cast<Waypoint*>(wpt);
         waypoints--;
         return;
 
       }
     }
-    wpt_a[wpt_a_ct++] = (Waypoint*)wpt;
+    wpt_a[wpt_a_ct++] = const_cast<Waypoint*>(wpt);
   }
 
 }
@@ -259,10 +259,10 @@ prework_wpt_cb(const Waypoint* wpt)
     cur_info->time += (wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t());
     cur_info->length += waypt_distance_ex(prev, wpt);
   } else {
-    cur_info->first_wpt = (Waypoint*)wpt;
+    cur_info->first_wpt = const_cast<Waypoint*>(wpt);
     cur_info->start = wpt->GetCreationTime().toTime_t();
   }
-  cur_info->prev_wpt = (Waypoint*)wpt;
+  cur_info->prev_wpt = const_cast<Waypoint*>(wpt);
   cur_info->count++;
   routepoints++;
 }
@@ -628,7 +628,7 @@ write_waypt(const Waypoint* wpt)
 static void
 route_disp_hdr_cb(const route_head* rte)
 {
-  current_trk = (route_head*)rte;
+  current_trk = const_cast<route_head*>(rte);
   cur_info = &route_info[route_idx];
   cur_info->prev_wpt = nullptr;
   cur_info->total = 0;
@@ -674,7 +674,7 @@ route_disp_wpt_cb(const Waypoint* wpt)
 
   gbfprintf(fout, "\r\n");
 
-  cur_info->prev_wpt = (Waypoint*)wpt;
+  cur_info->prev_wpt = const_cast<Waypoint*>(wpt);
 }
 
 static void
@@ -683,7 +683,7 @@ track_disp_hdr_cb(const route_head* track)
   cur_info = &route_info[route_idx];
   cur_info->prev_wpt = nullptr;
   cur_info->total = 0;
-  current_trk = (route_head*)track;
+  current_trk = const_cast<route_head*>(track);
   if (track->rte_waypt_ct <= 0) {
     return;
   }
@@ -745,7 +745,7 @@ track_disp_wpt_cb(const Waypoint* wpt)
   }
   gbfprintf(fout, "\r\n");
 
-  cur_info->prev_wpt = (Waypoint*)wpt;
+  cur_info->prev_wpt = const_cast<Waypoint*>(wpt);
 }
 
 /*******************************************************************************
diff --git a/gdb.cc b/gdb.cc
index d9aebea23432228979505271e71795f58221ade5..e1a2f99c80a783938587c633192ba2c2d89e324b 100644 (file)
--- a/gdb.cc
+++ b/gdb.cc
@@ -1629,7 +1629,7 @@ write_waypoint_cb(const Waypoint* refpt)
   /* do this when backup always happens in main */
 #if NEW_STRINGS
 // but, but, casting away the const here is wrong...
-  ((Waypoint*)refpt)->shortname = refpt->shortname.trimmed();
+  (const_cast<Waypoint*>(refpt))->shortname = refpt->shortname.trimmed();
 #else
   rtrim(((Waypoint*)refpt)->shortname);
 #endif
index 4f3b87c199bea3f62ac1b39440a8da52e46c2623..e691a5612a767fb17b6c43d5034ba66b02a047b1 100644 (file)
--- a/height.cc
+++ b/height.cc
@@ -87,7 +87,7 @@ double HeightFilter::wgs84_separation(double lat, double lon)
 
 void HeightFilter::correct_height(const Waypoint* wpt)
 {
-  Waypoint* waypointp = (Waypoint*) wpt;
+  Waypoint* waypointp = const_cast<Waypoint*>(wpt);
 
   if (waypointp->altitude != unknown_alt) {
     if (addopt) {
index d58d1ffb8d817c1f121317f84e28976494a3711a..c65afb90c68be8012bbfe6c7d7b26488afe44235 100644 (file)
@@ -953,13 +953,13 @@ humminbird_write_waypoint_wrapper(const Waypoint* wpt)
 
   xasprintf(&key, "%s\01%.9f\01%.9f", CSTRc(wpt->shortname), wpt->latitude, wpt->longitude);
   if (!(tmpwpt = map[key])) {
-    tmpwpt = (Waypoint*)wpt;
-    map[key] = (Waypoint*) wpt;
+    tmpwpt = const_cast<Waypoint*>(wpt);
+    map[key] = const_cast<Waypoint*>(wpt);
     tmpwpt->extra_data = gb_int2ptr(waypoint_num + 1); /* NOT NULL */
     humminbird_write_waypoint(wpt);
   } else {
     void* p = tmpwpt->extra_data;
-    tmpwpt = (Waypoint*)wpt;
+    tmpwpt = const_cast<Waypoint*>(wpt);
     tmpwpt->extra_data = p;
   }
 
index a2a0a2fdb882918e193bf2cc5d8e58fa23df9913..54cd5c13dbba4d2c112e50cf2ac20ae1122c5263 100644 (file)
@@ -300,7 +300,7 @@ static void
 register_waypt(const Waypoint* ref)
 {
   int i;
-  Waypoint* wpt = (Waypoint*) ref;
+  Waypoint* wpt = const_cast<Waypoint*>(ref);
 
   for (i = 0; i < waypt_table_ct; i++) {
     Waypoint* cmp = waypt_table[i];
diff --git a/mmo.cc b/mmo.cc
index 98565698123b0db33711a5864734846a6efef863..b4b103e200fdea0dfb1569b9e4f307a054029572 100644 (file)
--- a/mmo.cc
+++ b/mmo.cc
@@ -250,7 +250,7 @@ mmo_register_object(const int objid, const void* ptr, const gpsdata_type type)
   mmo_data_t* data;
 
   data = (mmo_data_t*) xcalloc(1, sizeof(*data));
-  data->data = (void*)ptr;
+  data->data = const_cast<void*>(ptr);
   data->visible = 1;
   data->locked = 0;
   data->type = type;
@@ -956,7 +956,7 @@ mmo_read_object()
 static void
 mmo_finalize_rtept_cb(const Waypoint* wptref)
 {
-  Waypoint* wpt = (Waypoint*)wptref;
+  Waypoint* wpt = const_cast<Waypoint*>(wptref);
 
   if ((wpt->shortname[0] == 1) && (wpt->latitude == 0) && (wpt->longitude == 0)) {
     mmo_data_t* data;
@@ -1340,7 +1340,7 @@ mmo_write_rte_head_cb(const route_head* rte)
     return;
   }
 
-  mmo_rte = (route_head*)rte;
+  mmo_rte = const_cast<route_head*>(rte);
 
   QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
     Waypoint* wpt = (Waypoint*)elem;
diff --git a/osm.cc b/osm.cc
index 869916bac3857d367ed4c5a9266da87d0c439793..6cb3a55a66793be5b5a59cb97504bae7556cefe5 100644 (file)
--- a/osm.cc
+++ b/osm.cc
@@ -461,7 +461,7 @@ osm_strip_html(const char* str)
 {
   utf_string utf;
   utf.is_html = true;
-  utf.utfstring = (char*)str;
+  utf.utfstring = const_cast<char*>(str);
 
   return strip_html(&utf);     // util.cc
 }
@@ -775,7 +775,7 @@ static void
 osm_release_ids(const Waypoint* wpt)
 {
   if (wpt && wpt->extra_data) {
-    Waypoint* tmp = (Waypoint*)wpt;
+    Waypoint* tmp = const_cast<Waypoint*>(wpt);
     xfree(tmp->extra_data);
     tmp->extra_data = nullptr;
   }
@@ -806,7 +806,7 @@ osm_waypt_disp(const Waypoint* wpt)
 
   id = (int*) xmalloc(sizeof(*id));
   *id = --node_id;
-  ((Waypoint*)(wpt))->extra_data = id;
+  (const_cast<Waypoint*>(wpt))->extra_data = id;
 
   gbfprintf(fout, "  <node id='%d' visible='true' lat='%0.7f' lon='%0.7f'", *id, wpt->latitude, wpt->longitude);
   if (wpt->creation_time.isValid()) {
index 778a503a1df8894c89de5d2ce110a027edd1c0e0..5b9688253c7f2fc3f363f62071f7275e11f157b2 100644 (file)
@@ -134,8 +134,8 @@ void PositionFilter::position_process_any_route(const route_head* rh, int type)
   int i = rh->rte_waypt_ct;
 
   if (i) {
-    cur_rte = (route_head*)rh;
-    position_runqueue((queue*)&rh->waypoint_list, i, type);
+    cur_rte = const_cast<route_head*>(rh);
+    position_runqueue(const_cast<queue*>(&rh->waypoint_list), i, type);
     cur_rte = nullptr;
   }
 
index 6de96185a98b451813c27e437ad0b76a09dad025..b31be2f0ae6043c714ba43da2ea3e69b3d91985d 100644 (file)
@@ -288,7 +288,7 @@ static void
 register_waypt(const Waypoint* ref, const char)
 {
   int i;
-  Waypoint* wpt = (Waypoint*) ref;
+  Waypoint* wpt = const_cast<Waypoint*>(ref);
 
   for (i = 0; i < waypt_table_ct; i++) {
     Waypoint* cmp = waypt_table[i];
@@ -317,13 +317,13 @@ register_waypt(const Waypoint* ref, const char)
 static void
 enum_waypt_cb(const Waypoint* wpt)
 {
-  register_waypt((Waypoint*) wpt, 0);
+  register_waypt(const_cast<Waypoint*>(wpt), 0);
 }
 
 static void
 enum_rtept_cb(const Waypoint* wpt)
 {
-  register_waypt((Waypoint*) wpt, 1);
+  register_waypt(const_cast<Waypoint*>(wpt), 1);
 }
 
 static int
index b8202be4798afd849f9a4962d06a10ab5e24cdc8..182c04df35fa85d2ca4a7b1304a1665c010f1ce8 100644 (file)
@@ -33,7 +33,7 @@ void ReverseRouteFilter::reverse_route_wpt(const Waypoint* waypointp)
 {
 
   /* Cast away const-ness */
-  Waypoint* wpp = (Waypoint*) waypointp;
+  Waypoint* wpp = const_cast<Waypoint*>(waypointp);
 
   int curr_new_trkseg;
 
index 631c218d13590ddf8bff5c16419a9303bc38c2c8..cc440fa849a1a358c9fb5b9b431b5bb088a99b6c 100644 (file)
--- a/route.cc
+++ b/route.cc
@@ -263,7 +263,7 @@ void
 route_reverse(const route_head* rte_hd)
 {
   /* Cast away const-ness */
-  route_head* rh = (route_head*) rte_hd;
+  route_head* rh = const_cast<route_head*>(rte_hd);
   queue* elem, *tmp;
   QUEUE_FOR_EACH(&rh->waypoint_list, elem, tmp) {
     ENQUEUE_HEAD(&rh->waypoint_list, dequeue(elem));
index 7dd66f32682f1263121273d110c40310e84ed9cc..fd76f2cb3d7d230abf14a15291443ab1de65dfde 100644 (file)
--- a/stmsdf.cc
+++ b/stmsdf.cc
@@ -509,7 +509,7 @@ any_hdr_calc_cb(const route_head* trk)
     rte_desc = trk->rte_desc;
   }
 
-  trk_out = (route_head*)trk;
+  trk_out = const_cast<route_head*>(trk);
 }
 
 static void
@@ -544,7 +544,7 @@ any_waypt_calc_cb(const Waypoint* wpt)
     this_time += (wpt->GetCreationTime().toTime_t() - trkpt_out->GetCreationTime().toTime_t());
   }
 
-  trkpt_out = (Waypoint*)wpt;
+  trkpt_out = const_cast<Waypoint*>(wpt);
 }
 
 static void
@@ -566,7 +566,7 @@ track_disp_hdr_cb(const route_head* trk)
 {
   track_index++;
   track_points = 0;
-  trk_out = (route_head*)trk;
+  trk_out = const_cast<route_head*>(trk);
   trkpt_out = nullptr;
 }
 
@@ -630,7 +630,7 @@ track_disp_wpt_cb(const Waypoint* wpt)
     gbfprintf(fout, ",0\n");
   }
 
-  trkpt_out = (Waypoint*)wpt;
+  trkpt_out = const_cast<Waypoint*>(wpt);
 }
 
 static void
index 1204a5017e618c34845b55f46a1874cfd0b159fb..25dfa3938132dc619f6b9b7862ecaa37372066ab 100644 (file)
@@ -30,7 +30,7 @@
 
 void SwapDataFilter::swapdata_cb(const Waypoint* ref)
 {
-  Waypoint* wpt = (Waypoint*)ref;
+  Waypoint* wpt = const_cast<Waypoint*>(ref);
   double x;
 
   x = wpt->latitude;
index f5258559d20bb1320f77fedd3c279d4ae47af640..22ddcd86a51508528fc4af3d3cdaf82f0073e7b9 100644 (file)
@@ -60,7 +60,7 @@ int TrackFilter::trackfilter_parse_time_opt(const char* arg)
 {
   time_t t0, t1;
   int sign = 1;
-  char* cin = (char*)arg;
+  char* cin = const_cast<char*>(arg);
   char c;
 
   t0 = t1 = 0;
@@ -178,7 +178,7 @@ void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track)   /* ca
   queue* elem, *tmp;
 
   if (track->rte_waypt_ct == 0) {
-    track_del_head((route_head*)track);
+    track_del_head(const_cast<route_head*>(track));
     return;
   }
 
@@ -186,15 +186,15 @@ void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track)         /* ca
     if (!QRegExp(opt_name, Qt::CaseInsensitive, QRegExp::WildcardUnix).exactMatch(track->rte_name)) {
       QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) {
         Waypoint* wpt = (Waypoint*)elem;
-        track_del_wpt((route_head*)track, wpt);
+        track_del_wpt(const_cast<route_head*>(track), wpt);
         delete wpt;
       }
-      track_del_head((route_head*)track);
+      track_del_head(const_cast<route_head*>(track));
       return;
     }
   }
 
-  track_list[track_ct].track = (route_head*)track;
+  track_list[track_ct].track = const_cast<route_head*>(track);
 
   i = 0;
   prev = nullptr;
@@ -234,7 +234,7 @@ void TrackFilter::trackfilter_minpoint_list_cb(const route_head* track)
 {
   int minimum_points = atoi(opt_minpoints);
   if (track->rte_waypt_ct < minimum_points) {
-    track_del_head((route_head*)track);
+    track_del_head(const_cast<route_head*>(track));
     return;
   }
 }
@@ -747,7 +747,7 @@ time_t TrackFilter::trackfilter_range_check(const char* timestr)
 
   i = 0;
   strncpy(fmt, "00000101000000", sizeof(fmt));
-  cin = (char*)timestr;
+  cin = const_cast<char*>(timestr);
 
   while ((c = *cin++)) {
     if (fmt[i] == '\0') {
@@ -1044,7 +1044,7 @@ void TrackFilter::trackfilter_segment_head(const route_head* rte)
           Waypoint* next_wpt = (Waypoint*) QUEUE_NEXT(&wpt->Q);
           if (trackfilter_points_are_same(prev_wpt, wpt) &&
               trackfilter_points_are_same(wpt, next_wpt)) {
-            track_del_wpt((route_head*)rte, wpt);
+            track_del_wpt(const_cast<route_head*>(rte), wpt);
             continue;
           }
         }
index 5713ea6283ce2238a717675738814233d4b8e545..55b79acd08fc1488a4a19d6b7bfda965b980b4f4 100644 (file)
--- a/unicsv.cc
+++ b/unicsv.cc
@@ -462,7 +462,7 @@ unicsv_adjust_time(const time_t time, time_t* date)
 static char
 unicsv_compare_fields(const char* s, const field_t* f)
 {
-  char* name = (char*)f->name;
+  char* name = const_cast<char*>(f->name);
   const char* test = s;
   char result;
 
diff --git a/util.cc b/util.cc
index dfe4e621327c3fae95c0a30e161d97b7ba0abef2..66a1dab07768e6d233b043a782fbcadd22a92942 100644 (file)
--- a/util.cc
+++ b/util.cc
@@ -124,7 +124,7 @@ XFREE(const void* mem, DEBUG_PARAMS)
 xfree(const void* mem)
 #endif
 {
-  free((void*) mem);
+  free(const_cast<void*>(mem));
 #ifdef DEBUG_MEM
   debug_mem_output("free, %x, %s, %d\n",
                    mem, file, line);
@@ -167,7 +167,7 @@ xstrndup(const char* str, size_t sz)
 #endif
 {
   size_t newlen = 0;
-  char* cin = (char*)str;
+  char* cin = const_cast<char*>(str);
   char* newstr;
 
   while ((newlen < sz) && (*cin != '\0')) {
@@ -484,8 +484,8 @@ str_match(const char* str, const char* match)
 {
   char* m, *s;
 
-  s = (char*)str;
-  m = (char*)match;
+  s = const_cast<char*>(str);
+  m = const_cast<char*>(match);
 
   while (*m || *s) {
     switch (*m) {
@@ -1121,7 +1121,7 @@ gstrsub(const char* s, const char* search, const char* replace)
 {
   int ooffs = 0;
   char* o, *c;
-  char* src = (char*)s;
+  char* src = const_cast<char*>(s);
   int olen = strlen(src);
   int slen = strlen(search);
   int rlen = strlen(replace);
@@ -1212,7 +1212,7 @@ convert_human_date_format(const char* human_datef)
   prev = '\0';
   ylen = 0;
 
-  for (cin = (char*)human_datef; *cin; cin++) {
+  for (cin = const_cast<char*>(human_datef); *cin; cin++) {
     char okay = 1;
 
     if (toupper(*cin) != 'Y') {
@@ -1278,7 +1278,7 @@ convert_human_time_format(const char* human_timef)
   cout = result;
   prev = '\0';
 
-  for (cin = (char*)human_timef; *cin; cin++) {
+  for (cin = const_cast<char*>(human_timef); *cin; cin++) {
     int okay = 1;
 
     if (isalpha(*cin)) {
diff --git a/vecs.cc b/vecs.cc
index f92b43acaf7c6f8c94fb745ab35130368dba1682..5417f1af370e05d2e3d8502a89e94363568a4a96 100644 (file)
--- a/vecs.cc
+++ b/vecs.cc
@@ -1179,7 +1179,7 @@ assign_option(const char* module, arglist_t* ap, const char* val)
   if (case_ignore_strcmp(val, ap->argstring) == 0) {
     c = "";
   } else {
-    c = (char*)val;
+    c = const_cast<char*>(val);
   }
 
   switch (ap->argtype & ARGTYPE_TYPEMASK) {
@@ -1290,7 +1290,7 @@ find_vec(const char* vecname, const char** opts)
           if (opt) {
             found = 1;
             assign_option(svecname, ap, opt);
-            xfree((char*)opt);
+            xfree(const_cast<char*>(opt));
             continue;
           }
         }
@@ -1347,7 +1347,7 @@ find_vec(const char* vecname, const char** opts)
           if (opt) {
             found = 1;
             assign_option(svecname, ap, opt);
-            xfree((char*)opt);
+            xfree(const_cast<char*>(opt));
             continue;
           }
         }